<?php
class AppController extends Controller {

    var $components = array('Acl', 'Auth', 'Session', 'Access');
    var $helpers = array('Html', 'Form', 'Session', 'Javascript');

    function beforeFilter() {
        //Configure AuthComponent
        $this->Auth->authorize = 'actions';
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'index');
        $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'bienvenido');
        $this->Auth->actionPath = 'controllers/';
       // $this->Auth->allowedActions = array('display');    
        $this->Auth->allowedActions = array('*');
    }
    
    function beforeRender() {
    	foreach($this->modelNames as $model) {
	      foreach($this->$model->_schema as $var => $field) {
	      	if(strpos($field['type'], 'enum') === FALSE)
	      	continue;
	
	      	preg_match_all("/\'([^\']+)\'/", $field['type'], $strEnum);
	
	      	if(is_array($strEnum[1])) {
	      		$varName = Inflector::camelize(Inflector::pluralize($var));
	      		$varName[0] = strtolower($varName[0]);
	      		$this->set($varName, array_combine($strEnum[1], $strEnum[1]));
	      	}
	      }
    	}
    }
}
?>